What is the difference between X:name and x:key?
5404
14-Oct-2013
Anonymous User
14-Oct-2013x:Key-X:Key identifies objects in resources section, can be accessed by resourceDictionary .x:key is used for items that are being added as values to a dictionary, most for styles and other resources that are being added to a ResourceDictionary. When setting the x:Key attribute, there is actually no corresponding property on the object or even an attached dependency property being set. It is simply used by the XAML processor to know what key to use when calling Dictionary.Add.
x:Name-X:name idetifies a UIElment in XAML Tree is a bit more complicated. x:Name- used to apply an associated name to an object (typically an object derived from FrameworkElement) within the scope of some parent element. This scope is called a "namescope" and the easiest way to think of it is to imagine a UserControl that contains a <TextBox x:Name="foo" />.